<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #img{
            position: fixed;
            top: 50%;
            left: 50%;
            margin-top: -100px;
            margin-left: -200px;
            width: 400px;
            height: 200px;
            background: url(image/1.png) no-repeat center;
            background-size: cover;
        }
        #left{
            background-color: rgb(0, 0, 0, 0.3);
            color: rgb(255, 255, 255, 0.5);
            height: 30px;
            width: 20px;
            position: relative;
            top: 85px;
            text-align: center;
            font-size: 20px;
            cursor: pointer;
        }
        #right{
            background-color: rgb(0, 0, 0, 0.3);
            color: rgb(255, 255, 255, 0.5);
            height: 30px;
            width: 20px;
            position: relative;
            top: 55px;
            left: 380px;
            text-align: center;
            font-size: 20px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="img">
        <div id="left"><</div>
        <div id="right">></div>
    </div>
    <script>
        var a=0
        document.getElementById('left').onclick=function(){
            if (a==0) 
            {
                document.getElementById('img').style.backgroundImage="url(image/2.png)";
                a=-1;
            } 
            if (a==1) {
                document.getElementById('img').style.backgroundImage="url(image/1.png)"
                a=0
            }
        }
        document.getElementById('right').onclick=function(){
            if (a==0) {
                document.getElementById('img').style.backgroundImage="url(image/3.png)"
                a=1
            } 
            if (a==-1) {
                document.getElementById('img').style.backgroundImage="url(image/1.png)"
                a=0
            }
        }
    </script>
</body>
</html>